<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="tutorial.css">
<TITLE>
Modelling with CLP and ECLiPSe
</TITLE>
</HEAD>
<BODY >
<A HREF="tutorial081.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="tutorial079.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="tutorial083.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc153">11.3</A>&nbsp;&nbsp;Modelling with CLP and ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP></H2>
When modelling problems with constraints, the basic idea is to set up
a network of variables and constraints. Figure <A HREF="#figconsnet">11.1</A> shows
such a constraint network.
<BLOCKQUOTE CLASS="figure"><DIV CLASS="center"><HR WIDTH="80%" SIZE=2></DIV>
<DIV CLASS="center">
<IMG SRC="tutorial031.gif">
</DIV>
<BR>
<BR>
<DIV CLASS="center">Figure 11.1: A Constraint Network</DIV><BR>
<BR>

<A NAME="figconsnet"></A>
<DIV CLASS="center"><HR WIDTH="80%" SIZE=2></DIV></BLOCKQUOTE>
It can be seen that the Constraint Logic Programming (CLP) formulation
<UL CLASS="itemize"><LI CLASS="li-itemize">
is a natural declarative description of the constraint network
<LI CLASS="li-itemize">can serve as a program to set up the constraint network
</UL>

The main ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> language constructs used in modelling are
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<B>Built-in constraints</B><DD CLASS="dd-description"><BR>
<CODE>X #&gt; Y</CODE>
<DT CLASS="dt-description"><B>Abstraction</B><DD CLASS="dd-description"><BR>
<CODE>before(task(Si,Di), task(Sj,Dj)) :- Si+Di #&lt;= Sj.</CODE>
<DT CLASS="dt-description"><B>Conjunction</B><DD CLASS="dd-description"><BR>
<CODE>between(X,Y,Z) :- X #&lt; Y, Y #&lt; Z.</CODE>
<DT CLASS="dt-description"><B>Disjunction (but see below)</B><DD CLASS="dd-description"><BR>
<CODE>neighbour(X,Y) :- ( X #= Y+1 ; Y #= X+1 ).</CODE>
<DT CLASS="dt-description"><B>Iteration</B><DD CLASS="dd-description"><BR>
<CODE>not_among(X, L) :- ( foreach(Y,L),param(X) do X #\= Y ).</CODE>
<DT CLASS="dt-description"><B>Recursion</B><DD CLASS="dd-description"><BR>
<CODE>not_among(X, []).</CODE><BR>
<CODE>not_among(X, [Y|Ys]) :- X #\= Y, not_among(X, Ys).</CODE>
</DL>
<HR>
<A HREF="tutorial081.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="tutorial079.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="tutorial083.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
